﻿<template>
	<div >
		<el-card shadow="hover" :body-style="{ paddingBottom: '0' }">
					<el-form :model="queryParams" ref="queryForm" :inline="true">
						<el-row :gutter="35">
						
			              <el-col :xs="24" :sm="12" :md="8" :lg="6" :xl="6" >
			              <el-form-item>
			              <el-input v-model="queryParams.num" clearable placeholder="堆垛机编号"/>
			              </el-form-item>
			              </el-col>
						
                
			          <el-col :xs="24" :sm="12" :md="12" :lg="12" :xl="12" class="mb20 search-actions">
         
			          <div>
			          <el-button icon="ele-Refresh" @click="() => queryParams = {}"> 重置 </el-button>
			          <el-button type="primary" plain icon="ele-Search" @click="handleQuery" v-auth="'outTask:page'"> 查询 </el-button>
			          </div>
			          </el-col>
			      </el-row>
			      </el-form>
	   </el-card>
		<el-card shadow="hover" style="margin-top: 8px">
			<el-table
				:data="tableData"
				style="width: 100%"
				v-loading="loading"
				tooltip-effect="light"
				row-key="id"
				border="">
				<el-table-column type="index" label="序号" width="55" align="center" fixed="" />
				<el-table-column prop="equipNum" label="堆垛机" width="70" show-overflow-tooltip="" />
				<el-table-column prop="data" label="托盘号" width="80" show-overflow-tooltip="" >
					<template #default="scope">
					       {{ scope.row.tray }}-{{ scope.row.tray2 }}
			        </template>
				 </el-table-column>
				 <el-table-column prop="jobID" label="任务ID" width="90" show-overflow-tooltip="" />
				 <el-table-column prop="usePoke" label="使用叉" width="85" show-overflow-tooltip="" />
				
				 <el-table-column prop="toTagNumber" label="放货物流线" width="100" show-overflow-tooltip="" />
				 <el-table-column  label="取货" width="80" show-overflow-tooltip="" >
					<template #default="scope">
					       {{ scope.row.fromX }}-{{ scope.row.fromY }}-{{ scope.row.fromZ }}
			</template>
		  </el-table-column>
		  <el-table-column  label="放货" width="80" show-overflow-tooltip="" >
			<template #default="scope">
					       {{ scope.row.toX }}-{{ scope.row.toY }}-{{ scope.row.toZ }}
			</template>
		  </el-table-column>


		  <el-table-column prop="jobID2" label="任务ID2" width="90" show-overflow-tooltip="" />
			
				 <el-table-column prop="toTagNumber2" label="放货物流线2" width="110" show-overflow-tooltip="" />
				 <el-table-column  label="取货2" width="80" show-overflow-tooltip="" >
			<template #default="scope">
					       {{ scope.row.fromX2 }}-{{ scope.row.fromY2 }}-{{ scope.row.fromZ2 }}
			</template>
		 </el-table-column>	

		 <el-table-column  label="放货2" width="80" show-overflow-tooltip="" >
			<template #default="scope">
					       {{ scope.row.toX2 }}-{{ scope.row.toY2 }}-{{ scope.row.toZ2 }}
			</template>
		 </el-table-column>	

		 <el-table-column prop="data" label="右叉托盘" width="80" show-overflow-tooltip="" >
					<template #default="scope">
					       {{ scope.row.rightTray }}-{{ scope.row.rightTray2 }}
			        </template>
				 </el-table-column>

		 <el-table-column prop="createTime" width="155" label="创建时间"   show-overflow-tooltip="" />
		 <el-table-column prop="runTime" width="155" label="启动时间"   show-overflow-tooltip="" />

		
		


		 <el-table-column  width="100" label="状态"   show-overflow-tooltip="" >
			<template #default="scope">
				       
					   <el-tag  
						 :type="scope.row.isError>0 ? 'danger' :scope.row.status==1?'success':'info'"
						 disable-transitions >{{ scope.row.status==1?'已启动':scope.row.status==2?'启动完成':'未启动'}}
					   </el-tag>
					 </template>
		 </el-table-column>
		  
				<el-table-column  width="80" prop="isError" label="错误码"   show-overflow-tooltip="" />

				<el-table-column  label="错误信息"   show-overflow-tooltip="" >
			<template #default="scope">
				       
				<el-tag v-if="scope.row.errorMsg" 
						 type='danger'
						 disable-transitions >{{ scope.row.errorMsg}}
					   </el-tag>
					 </template>
		 </el-table-column>
				
				  
				<el-table-column label="操作" width="140" align="center" fixed="right" show-overflow-tooltip="" >
					<template #default="scope">
						
						<el-button icon="ele-Close" size="small" text="" type="primary" @click="deleteControl(scope.row)" v-auth="'outTask:control'"> 删除 </el-button>
						<el-button icon="ele-Check" size="small" text="" type="primary" @click="completeControl(scope.row)" v-auth="'outTask:control'"> 完成 </el-button>
					</template>
				</el-table-column>
			</el-table>
			
			
		</el-card>
	</div>
</template>

<script lang="ts" setup>
	import { ref } from "vue";
	import { ElMessageBox, ElMessage } from "element-plus";
	import { auth } from '/@/utils/authFunction';
	//import { formatDate } from '/@/utils/formatTime';

	
	import { GetOutJob,RemoveOutJob,CompleteOutJob,GetProcessData } from '/@/api/main/grpcServer';


		
		const loading = ref(false);
		const tableData = ref<any>([]);
		const queryParams = ref<any>(
		{	
			num:''
		});
	
	const tableParams = ref({
	page: 1,
	pageSize: 10,
	total: 0,
	});

	

	// 查询操作
	const handleQuery = async () => {
		loading.value = true;
	let para={
		nums:queryParams.value.num,
		providerType:2
		};
	
	var res = await GetProcessData(para);
	tableData.value = res.data.result ?? [];
	tableParams.value.total = res.data.result?.length;
	loading.value = false;
};





 


const deleteControl=async(row:any)=>{

ElMessageBox.confirm(
'是否删除出库任务?',
'警告',
{
  confirmButtonText: '确定',
  cancelButtonText: '取消',
  type: 'warning',
}
)
.then(async() => {


 await RemoveOutJob(row);
  ElMessage({
	type: 'success',
	message: '操作完成',
  })
})

};

const completeControl=async(row:any)=>{
ElMessageBox.confirm(
'是否完成出库任务？完成失败请手动发走托盘',
'警告',
{
  confirmButtonText: '确定',
  cancelButtonText: '取消',
  type: 'warning',
}
)
.then(async() => {
 await CompleteOutJob({taskNumberId:row.jobID,taskNumberId2:row.jobID2});
  ElMessage({
	type: 'success',
	message: '操作完成',
  })
})


};





handleQuery();
</script>


